class Animal:
    def sound(self):
        """返回动物的声音"""
        pass


class Dog(Animal):
    def sound(self):
        """犬类动物的声音"""
        return "Woof!"


class Cat(Animal):
    def sound(self):
        """猫类动物的声音"""
        return "Meow!"

    # 实例化子类


my_dog = Dog()
my_cat = Cat()

# 通过基类引用来调用这些方法
animals = [my_dog, my_cat]
for animal in animals:
    print(animal.sound())  # 输出对应动物的声音
